package cn.nicklemay.interview.algorithm;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

public class NO300
{
    public int lengthOfLIS(int[] nums) {
        List<Stack<Integer>> list = new LinkedList<Stack<Integer>>();
        for (int n : nums)
        {
            if (list.isEmpty() || !insert(list, n))
            {
                Stack<Integer> s = new Stack<Integer>();
                s.push(n);
                list.add(s);
            }
        }
        return list.size();
    }

    private boolean insert(List<Stack<Integer>> list, Integer i)
    {
        boolean b = false;
        for (Stack<Integer> s : list)
        {
            int peek = s.peek();
            if (peek >= i)
            {
                s.push(i);
                b = true;
                break;
            }
        }
        return b;
    }

    public static void main(String[] args) throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums = IOUtil.stringToIntegerArray(line);

            int ret = new NO300().lengthOfLIS(nums);

            String out = String.valueOf(ret);

            System.out.print(out);
        }
    }
}

